#ifndef _FRAMEWORK_ICAN_H_
#define _FRAMEWORK_ICAN_H_

#include <iostream>
#include <vector>
#include "zlgcan.h"
#include <functional>

enum class OperationResult : uint8_t
{
    Success = 0x00,
    Fail_UnknownReason = 0x01,
    DeviceIsNotOpen = 0x02,
    SetBaudrateFail = 0x03,
    SetCustomBaudrateFail = 0x04,
    SetUsbCanFdBaudrateFail = 0x05,
    InitCanFail = 0x06,
    SetResistanceEnableFail = 0x07,
    StartFail = 0x08,
    ResteFail = 0x09,
    StopFail = 0x0a,
    SendCanDataFail = 0x0b,
};

enum class SendType : uint8_t
{
    StandardFrame = 0x00,
    ExtendedFrame = 0x01,
};

class ICan
{
public:
    ICan() = default;
    virtual ~ICan() = default;

    virtual OperationResult OpenCan() = 0;
    virtual OperationResult CloseCan() = 0;
    virtual bool IsDeviceOnLine() = 0;
    virtual OperationResult SendCanMsg(const uint32_t canId, const SendType& sendType, const std::vector<uint8_t>& data) = 0;
    virtual OperationResult SendCanfdMsg(const uint32_t canId, const SendType& sendType, const std::vector<uint8_t>& data) = 0;
    virtual void reigsterListenerCb(std::function<void(ZCAN_Receive_Data*)>) = 0;

    static constexpr const int   MAX_RECV_SIZE = 100;
};

#endif
